/**
 * @file Task.h
 * @author zeppyrz (zeppyrz@gmail.com)
 * @brief Task class
 * @version 0.1
 * @date 2025-11-03
 *
 * @copyright Copyright (c) 2025
 *
 */

#ifndef ZEDISK_TASK_H
#define ZEDISK_TASK_H

#include "ExportDLL.h"

// forward declaration
struct event_base;

namespace ZeDisk {

/**
 * @brief Task interface
 */
class DECLSPEC Task {
 public:
  Task() = default;
  virtual ~Task() = default;
  /**
   * @brief 初始化任务
   *
   * @return bool
   */
  virtual bool Init() = 0;
  /**
   * @brief Task 清理资源
   * @return bool
   */
  virtual bool Stop() = 0;
  /**
   * @brief Task 是否完成
   * @return bool
   */
  [[nodiscard]] bool &Completed() { return completed_; }

  [[nodiscard]] event_base*& base() { return base_; }
  [[nodiscard]] int& sockfd() { return sockfd_; }
  [[nodiscard]] int& thread_id() { return thread_id_; }

 protected:
  event_base* base_ = nullptr;
  int sockfd_ = -1;
  int thread_id_ = -1;
  bool completed_ = false;
};

}  // namespace ZeDisk

#endif  // ZEDISK_TASK_H